home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pkscrypt.arc / PKSCRYPT.DOC < prev    next >
Text File  |  1986-03-29  |  13KB  |  270 lines

  1.  
  2.            Public Key System for Encryption and Digital Signatures
  3.  
  4.                        Copyright (c) Lloyd Miller, 1985
  5.                                Calgary, Alberta
  6.  
  7.  
  8.  
  9.     Public  Key  Encryption  is  a  system  of  encrypting  messages where the
  10. encryption  and  decryption  keys  are  different.  The,  so  called,   public
  11. encryption key, used to encrypt messages is related to the private  decryption
  12. key but it is very difficult to figure out the decyrption key if you only know
  13. the encryption key. (If you think this is confusing, you're right.)
  14.  
  15.     To send a  secret message to  someone you need  to know only  their public
  16. key. For anyone to send you a  secret message, you need to let them  know your
  17. public key. I have included my public key with these files so that anyone  who
  18. gets this system  can send me  a secret message  (I don't know  why they might
  19. want to but they can). If someone wants me to reply (secretly) then they would
  20. have to send me their public key.
  21.  
  22.     Messages can  also be  encrypted with  the private  key. This  is called a
  23. signature. Anyone who knows  the public key can  decrypt the message but  only
  24. the person  who knows  the corresponding  private key  could have  created the
  25. message. I have included a message signed by me in this archive that can  only
  26. be decoded with my  public key and thus  could only have been  encrypted by my
  27. private key. Since I havn't given my  private key to anyone and I don't  think
  28. anyone could have figured it out, you  should be able to safely assume that  I
  29. wrote the orginal message.  Signatures are not quite  as useful as the  normal
  30. encryption operation but they do have some very interesting capabilities.
  31.  
  32.     Messages can be encrypted more than  once. One use for this feature  is to
  33. sign a secret message. To do this  you encrypt the message with both the  your
  34. private key and the recipient's public key. The combination is a message which
  35. only the recipient can read and only you could have created. In order to  read
  36. the message it must be decrypted  twice using the recipeint's private key  and
  37. your public key in the reverse order that it was encrypted.
  38.  
  39.     The difficulty of  "breaking" the key  is dependant on  the length of  the
  40. keys used. Keys of  8 digits or smaller  are actually quite easy  to break. In
  41. fact you my find  a simple (hee hee)  basic program included with  these files
  42. for "cracking" keys of  5 to 8 digits  (called cracker.bas). I haven't  really
  43. tried it but a key of even 50 digits is estimated that it could be cracked  in
  44. about 4 hours using a super computer and the fastest factoring algoritm known.
  45. A key of  75 digits would  take 104 days  and a key  of 200 digits  would take
  46. 3,800,000,000 years. For more on this see the ACM article. If anyone cracks my
  47. 75 digit key I would like to hear about it. I suspect you would need a  Cray-2
  48. or equivalent to do it this year.
  49.  
  50.     The disadvantage of longer keys is that it takes longer to find and create
  51. the key and the encryption/decryption processes are slower as well. A 8  digit
  52. key  will  only  take  about  1/2  minute  to generate with this software on a
  53. standard IBM-PC. A 20 digit key takes  about 90 sec. A 50 digit key,  about 10
  54. min. A 200 digit key will take about 6 to 12 hours. These times may be  longer
  55. or shorter depending on your luck on the random number generator.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.     PKSCrypt is a program to perform  the three basic functions reqired for  a
  69. complete public  key encryption  system. The  first question  it asks  is what
  70. function you want to perform, Genkeys, Encrypt, Decrypt, or Quit.
  71.  
  72.     GENKEYS is the function to generate encryption and decryption keys for the
  73. RSA  (Rivest,  Shamir,   Adleman)  system  of   public  key  encryption.   See
  74. Communications of the ACM, February, 1978.
  75.  
  76.     GENKEYS takes, as the first input parameter, a single number from 5 to 200
  77. designating the number  of digits desired  in the key.  This number determines
  78. the level of security of the resulting cypher. It also determins the amount of
  79. time needed to generate a key.
  80.  
  81.     Also input is a name for the  key to be generated. This is an  8 character
  82. filename without extension.
  83.  
  84.     Output of the function  is two files (besides  all the stuff displayed  on
  85. the screen to keep you from  thinking the software has crashed). The  first is
  86. the public key file called keyname.KEY. It contains two numbers, each of which
  87. contains, at most, the number of digits requested. The first number is  called
  88. "n" and is the product of two large prime numbers (p and q). The second number
  89. is called "e" and is a  number which is relativly prime to  (p-1)*(q-1). These
  90. numbers are the, so called, public key.  This file is the one to be  given out
  91. and/or published for people who want to send you secret messages.
  92.  
  93.     The second file produced is called keyname.KDY. It also has two numbers in
  94. it. The first is "n" and is the same as the "n" in the public key. The  second
  95. number in this  file is called  "d" and is  the secret decryption  key. "d" is
  96. constructed such that (d * e) MOD ((p -  1) * (q - 1)) = 1. This file  is your
  97. private key for decrypting messages encrypted with your public key and must be
  98. kept secure and private. Perhaps keep it  on a floppy disk and locked up  when
  99. not in use, perhaps with extra copies in separate places.
  100.  
  101.     The key files are only significant up  to the end of the second number  in
  102. each  file  so  comments  may  be  added  at  the  end  of  the  file. This is
  103. particularily usefull for the public  key files where the name  and/or address
  104. can be added to the  key to indicate the owner  of the key. For an  example of
  105. this, see the file LLOYD.KEY included in this archive. That file is my  public
  106. key and can be used to send me secret messages. When you edit these files make
  107. sure  your  editor  does  not  break  any  long  lines into shorter lines. For
  108. instance a 200 digit key would have  over 200 characters in each of the  first
  109. two lines. These lines must not be broken up into shorter lines.
  110.  
  111.     The other two functions, ENCRYPT and DECRYPT, use the key files created by
  112. GENKEYS  to  encrypt  and  decrypt  other  files.  The time required for these
  113. functions to do their job depends on  the length of the key used and  the size
  114. of  the  file.  Any  file  can  be  encrypted  with  any key. They can only be
  115. decrypted with the opposite key of the pair.
  116.  
  117.     ENCRYPT, when selected, will ask for the name of the file to be  encrypted
  118. and the full name of the key file to be used for encryption (ie  "LLOYD.KEY").
  119. Third and last it will ask for a file name to store the encrypted file  under.
  120. ENCRYPT saves the name of the key  file used to encrypt in the output  file in
  121. plain text  so that  the decrypt  system can  easily figure  out which  key is
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. needed. It does not  store any keys in  the encrypted file, just  the key file
  134. name. Encrypt also saves the input  file name and size in the  encrypted file.
  135. This is so  the decryption can  reproduce the origninal  file. The input  file
  136. name and size  are encrypted so  no extra information  is obtainable from  the
  137. encrypted file without the decryption key.
  138.  
  139.     DECRYPT first asks for the name of the encrypted file. It reads the header
  140. and offers you the default name for the decryption key. (I.E. if the file  was
  141. encrypted with a key called "test.key" it will ask if you want to decrypt with
  142. "test.kdy".) Normally  you would  anser "yes"  to this  question. If  you have
  143. renamed the key file you want to use  then answer no and type in the name  you
  144. want to use. If you  tell the program the wrong  key to use then nothing  will
  145. work right  after that.  DECRYPT then  decodes the  first part  of the file to
  146. obtain the original file name and  size. Once it has decoded this  information
  147. it will ask you if you want to  use the original name for the decoded file  or
  148. you can enter a new filename. DECRYPT will then procede to decrypt the rest of
  149. the file.
  150.  
  151.  
  152.     PKSCrypt can be operated from the command line if you know in advance  the
  153. answers to ALL the questions which will be asked. Just type them following the
  154. command to start up the program. ie:
  155.  
  156.     pkscrypt genkeys 10 temp quit
  157.     pkscrypt e temp.key temp.dt1 temp.dt2 q
  158.     pkscrypt decrypt temp.dt2 yes yes quit
  159.  
  160.  
  161.     Anyone can make as many copies of this software as they want and give them
  162. away so long as the programs and this documentation are included in any copies
  163. and  all  files  are  in  their  original  unmodified  form.  In  fact you are
  164. encouraged to distribute this software  as much as possible by  whatever means
  165. you can  find, electronic,  magnetic, optical  or via  any future technologies
  166. which may be developed. If you find this system usefull then you can encourage
  167. me to write and distribute more of my software by sending $30 to:
  168.  
  169.         Lloyd Miller
  170.         2420 Capitol Hill Crescent, N.W.
  171.         Calgary, Alberta    T2M-4C2
  172.  
  173.     If you are a corporate or governmental user then the $30 is not  optional.
  174. If you need an invoice in order to  pay for this please feel free to make  one
  175. out. If you send me a SSAE I will send you a real invoice.
  176.  
  177.     This software and documentaion is protected by copyright and if you  don't
  178. think that means much then ask a lawyer.
  179.  
  180.     If you have comments, complaints (heaven forbid) or questions then you can
  181. either send a SASE to the above address or send a message to me (Lloyd Miller)
  182. via Fidonet(TM of Tom Jennings) node 134/1, "The Calgary Fido". If you want to
  183. send  encrypted  messages  via  Fidonet  then  you  will need your sysop's co-
  184. operation to send "attached files". Your  sysop will not be able to  read your
  185. secret messages. If you want  to send encrypted messages via  traditional mail
  186. then you would have to send floppy disks.
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.     This software is designed to run on an IBM-PC using MS-DOS version 2.00 or
  200. later.  I  have  tried  to  avoid  using  any features of the IBM-PC which are
  201. machine dependant so I believe it should work on any system which uses  MS-DOS
  202. or PC-DOS but it has not been  tested on many other types of systems.  I would
  203. like to hear from  you if you have  tried it on any  other systems and if  you
  204. have had any  probelms or not.  I have tested  the system on  a Sanyo MBC  555
  205. (with a V-20 CPU chip) and it works fine.
  206.  
  207.     These  programs  are  written  in  Modula-2 using the Logitech Modula-2/86
  208. compiler system. I would be willing to consider converting these programs  for
  209. use  with  other  Modula-2  systems  if  anyone  wants  to  pay  me  to do the
  210. convertion. I would not consider converting the programs to another  language.
  211. The nature of these programs  would probably eliminate from consideration  any
  212. M-CODE or P-CODE  interpreter style compiler  systems since they  would become
  213. prohibitivly slow.
  214.  
  215.  
  216.     Version History
  217.  
  218.         Version 0.0     Distributed as three  programs, GENKEYS, ENCRYPT,  and
  219. DECRYPT. Worked fine
  220.  
  221.         Version 0.01    Combined  the  three  programs  into  one  executable,
  222. PKSCRYPT, to save space on my disk. The same key files and encrypted files are
  223. used.
  224.  
  225.         Version 0.01a   Update to Version 2.0  of the compiler. Some  spelling
  226. corrections.
  227.  
  228.         Version 0.01b   Eliminated  last  few  remaining  REALS.  Added  a few
  229. "Please  Wait"  messages.  Documented  the  command  line  operation which has
  230. allways been available.
  231.  
  232.         Version 0.01c   Converted a few selected routines to mahine code.  Not
  233. much speed difference resulted. Hardly worth the effort.
  234.  
  235.         Version 0.01d   Allows   smaller   keys   (5   digits)   and  includes
  236. cracker.bas for breaking keys of 8 digits and smaller.
  237.  
  238.         Version 0.02    Changed the  long arithmetic  from byte  at a  time to
  239. word at a time.  Very nice speed improvement.  Generated a 200 digit  key in 4
  240. hours  40  min.  Minimum  key  size  increased  back up to 7 digits because of
  241. occational hangs on smaller keys.
  242.     Sample decrypt times for 10 byte message on regular 8088 at 4.77mhz.
  243.  
  244.         Key digits      V0.01d          V0.02
  245.  
  246.          10              0:12            0:12
  247.          20              0:20            0:15
  248.          30              0:31            0:15
  249.          40              1:02            0:26
  250.          50              1:42            0:38
  251.         200             36:57           10:29
  252.  
  253.         Version 0.02a   Found another bug in the long arithmetic. V0.02  would
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. occationally  dump  with  a  divide  by  zero. Some more speed-up implememted,
  266. relativly minor.
  267.  
  268.                                                                   Lloyd Miller
  269.                                                                  1986 March 29
  270.